/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Bram
 */
public class Bord extends JPanel implements KeyListener {

    private final int LEFT_ARROW = 37;
    private final int UP_ARROW = 38;
    private final int RIGHT_ARROW = 39;
    private final int DOWN_ARROW = 40;
    private final int LEFT_KEYPAD = 100;
    private final int UP_KEYPAD = 104;
    private final int RIGHT_KEYPAD = 102;
    private final int DOWN_KEYPAD = 98;
    
    private Image[][] veldArray = new Image[11][20];
    private Image[][] objectArray = new Image[11][20];
    private int veldGrootte = 36;
            
    public Bord() {
        setFocusable(true);
        setPreferredSize(new Dimension(1024,720));
        setBackground(Color.green);
        addKeyListener(this);
    }
    
    @Override
    public void keyTyped ( KeyEvent e ){  
        
    }  
    @Override
    public void keyPressed ( KeyEvent e){  
        
    }  
    @Override
    public void keyReleased ( KeyEvent e ){  
        int code = e.getKeyCode();
        switch (code) {
            case LEFT_ARROW:
            case LEFT_KEYPAD:
                
                break;
            case UP_ARROW:
            case UP_KEYPAD:
            
                break;
            case RIGHT_ARROW:
            case RIGHT_KEYPAD:
            
                break;
            case DOWN_ARROW:
            case DOWN_KEYPAD:
            
                break;
            
        }
    } 
    
    public void showWorld(){
        repaint();
    }
    
    public void buildWorld(Graphics g) {
       
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        g.setColor(new Color(250, 240, 170));
        
        int calcX = 0;
        int calcY = 0;
        for(int i = 0; i < 11 ; i++){
            for(int j = 0; j < 20; j++){
                if(veldArray[i][j] != null){
                    calcX = j + 1;
                    calcY = i + 1;
                    g.drawImage(veldArray[i][j], ( calcX * veldGrootte), ( calcY * veldGrootte), this);
                }
                if(objectArray[i][j] != null){
                    calcX = j + 1;
                    calcY = i + 1;
                    g.drawImage(objectArray[i][j], ( calcX * veldGrootte), ( calcY * veldGrootte), this);
                }
            }        
        }
    }
    
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        buildWorld(g);
    }

    public Image[][] getObjectArray() {
        return objectArray;
    }

    public void setObjectArray(Image[][] objectArray) {
        this.objectArray = objectArray;
    }

    public int getVeldGrootte() {
        return veldGrootte;
    }

    public void setVeldGrootte(int veldGrootte) {
        this.veldGrootte = veldGrootte;
    }

    public Image[][] getVeldArray() {
        return veldArray;
    }

    public void setVeldArray(Image[][] veldArray) {
        this.veldArray = veldArray;
    }
    
    
}
